<?php


class EmsValueTable extends Doctrine_Table
{
    public function addFindByFieldIdAndValueQuery($field_id, $value, Doctrine_Query $q = null)
    {
        if (is_null($q))
        {
            $q = Doctrine_Query::create()
                ->from('EmsValue v');
        }

        $alias = $q->getRootAlias();

        $q->andWhere($alias.'.field_id = ?',$field_id)
            ->andWhere($alias.'.value = ?', $value);

        return $q;
    }


    public function findByFieldIdAndValue($field_id,$value)
    {
        return $this->addFindByFieldIdAndValueQuery($field_id, $value)->execute();
    }


    public static function getInstance()
    {
        return Doctrine_Core::getTable('EmsValue');
    }
}